package org.p2psimulator.entity.filesystem;

import java.util.List;
import org.p2psimulator.entity.Id;
import org.p2psimulator.entity.Network;
import org.p2psimulator.entity.Peer;
import org.p2psimulator.entity.PeerBank;

/**
 *
 * @author Amorim
 */
public class FileDistTask implements Runnable {

    private double m;
    private List<Id> set;
    private PeerBank peerBank;

    

    public FileDistTask(double m, List<Id> set, PeerBank peerBank) {
        this.m = m;
        this.set = set;
        this.peerBank = peerBank;
    }

    public void run() {
        for (double i = m; i >= 0; i--) {
            Peer p = peerBank.getRandomPeer();
            if (p != null) {
                if (!set.contains(p.getId())) {
                    set.add(p.getId());
                }
            }
        }
    }

    public double getM() {
        return m;
    }

    public void setM(double m) {
        this.m = m;
    }

    public List<Id> getList() {
        return set;
    }

    public void setSet(List<Id> set) {
        this.set = set;
    }

    public PeerBank getNetwork() {
        return peerBank;
    }

    public void setNetwork(PeerBank network) {
        this.peerBank = network;
    }
}
